<template>
    <view class="device-message-page">
        <!-- 顶部导航栏 -->
        <view class="header-nav">
            <view class="nav-left" @tap="goBack">
                <text class="back-icon">‹</text>
            </view>
            <view class="nav-center">
                <text class="nav-title">商家设备信息</text>
            </view>
            <view class="nav-right"></view>
        </view>

        <!-- 设备总数统计 -->
        <view class="device-summary">
            <view class="total-devices">
                <text class="total-number">{{ totalDevices }}</text>
                <text class="total-label">设备总数(台)</text>
            </view>
            <view class="device-status-row">
                <view class="status-item">
                    <text class="status-number">{{ unboundCount }}</text>
                    <text class="status-text">未绑定</text>
                </view>
                <view class="status-divider"></view>
                <view class="status-item">
                    <text class="status-number">{{ boundCount }}</text>
                    <text class="status-text">已绑定</text>
                </view>
                <view class="status-divider"></view>
                <view class="status-item">
                    <text class="status-number">{{ unactivatedCount }}</text>
                    <text class="status-text">未激活</text>
                </view>
                <view class="status-divider"></view>
                <view class="status-item">
                    <text class="status-number">{{ activatedCount }}</text>
                    <text class="status-text">已激活</text>
                </view>
            </view>
        </view>

        <!-- 直属设备统计 -->
        <view class="device-section">
            <view class="section-header" @tap="goToDirectDevices">
                <text class="section-title">直属设备总数(台) {{ directDevices }}</text>
                <text class="arrow-icon">›</text>
            </view>
            <view class="device-stats">
                <view class="stats-left">
                    <view class="stat-item">
                        <text class="stat-number">{{ directUnbound }}</text>
                        <text class="stat-label">未绑定</text>
                    </view>
                    <view class="stat-item">
                        <text class="stat-number">{{ directUnactivated }}</text>
                        <text class="stat-label">未激活</text>
                    </view>
                </view>
                <view class="stats-right">
                    <view class="stat-item">
                        <text class="stat-number">{{ directBound }}</text>
                        <text class="stat-label">已绑定</text>
                        <view class="bubbles">
                            <view class="bubble bubble-today">今日+0</view>
                            <view class="bubble bubble-yesterday">昨日+0</view>
                            <view class="bubble bubble-month">本月+0</view>
                        </view>
                    </view>
                    <view class="stat-item">
                        <text class="stat-number">{{ directActivated }}</text>
                        <text class="stat-label">已激活</text>
                        <view class="bubbles">
                            <view class="bubble bubble-today">今日+0</view>
                            <view class="bubble bubble-yesterday">昨日+0</view>
                            <view class="bubble bubble-month">本月+0</view>
                        </view>
                    </view>
                </view>
            </view>
        </view>

        <!-- 下级设备统计 -->
        <view class="device-section">
            <view class="section-header" @tap="goToSubordinateDevices">
                <text class="section-title">下级设备总数(台) {{ subordinateDevices }}</text>
                <text class="arrow-icon">›</text>
            </view>
            <view class="device-stats">
                <view class="stats-left">
                    <view class="stat-item">
                        <text class="stat-number">{{ subordinateUnbound }}</text>
                        <text class="stat-label">未绑定</text>
                    </view>
                    <view class="stat-item">
                        <text class="stat-number">{{ subordinateUnactivated }}</text>
                        <text class="stat-label">未激活</text>
                    </view>
                </view>
                <view class="stats-right">
                    <view class="stat-item">
                        <text class="stat-number">{{ subordinateBound }}</text>
                        <text class="stat-label">已绑定</text>
                        <view class="bubbles">
                            <view class="bubble bubble-today">今日+0</view>
                            <view class="bubble bubble-yesterday">昨日+0</view>
                            <view class="bubble bubble-month">本月+0</view>
                        </view>
                    </view>
                    <view class="stat-item">
                        <text class="stat-number">{{ subordinateActivated }}</text>
                        <text class="stat-label">已激活</text>
                        <view class="bubbles">
                            <view class="bubble bubble-today">今日+0</view>
                            <view class="bubble bubble-yesterday">昨日+0</view>
                            <view class="bubble bubble-month">本月+0</view>
                        </view>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                // 设备总数统计
                totalDevices: 24,
                unboundCount: 4,
                boundCount: 20,
                unactivatedCount: 8,
                activatedCount: 16,
                
                // 直属设备统计
                directDevices: 12,
                directUnbound: 2,
                directUnactivated: 4,
                directBound: 10,
                directActivated: 8,
                
                // 下级设备统计
                subordinateDevices: 12,
                subordinateUnbound: 2,
                subordinateUnactivated: 4,
                subordinateBound: 10,
                subordinateActivated: 8
            }
        },
        methods: {
            goBack() {
                uni.navigateBack();
            },
            goToDirectDevices() {
                // 跳转到直属设备详情
                uni.showToast({
                    title: '跳转到直属设备详情',
                    icon: 'none'
                });
            },
            goToSubordinateDevices() {
                // 跳转到下级设备详情
                uni.showToast({
                    title: '跳转到下级设备详情',
                    icon: 'none'
                });
            }
        }
    }
</script>

<style lang="scss" scoped>
    .device-message-page {
        background-color: #f0f2f5;
        min-height: 100vh;

        // 顶部导航栏
        .header-nav {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 20rpx 30rpx;
            background: #427AF5;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 1000;

            .nav-left {
                width: 60rpx;
                height: 60rpx;
                display: flex;
                align-items: center;
                justify-content: center;

                .back-icon {
                    font-size: 48rpx;
                    color: #fff;
                    font-weight: bold;
                }
            }

            .nav-center {
                flex: 1;
                text-align: center;

                .nav-title {
                    font-size: 36rpx;
                    font-weight: bold;
                    color: #fff;
                }
            }

            .nav-right {
                width: 60rpx;
            }
        }

        // 设备总数统计
        .device-summary {
            background: #427AF5;
            padding: 40rpx 30rpx 60rpx 30rpx;
            margin-top: 100rpx;

            .total-devices {
                text-align: center;
                margin-bottom: 40rpx;

                .total-number {
                    display: block;
                    font-size: 80rpx;
                    font-weight: bold;
                    color: #fff;
                    margin-bottom: 10rpx;
                }

                .total-label {
                    font-size: 28rpx;
                    color: #fff;
                }
            }

            .device-status-row {
                display: flex;
                align-items: center;
                justify-content: space-around;

                .status-item {
                    text-align: center;

                    .status-number {
                        display: block;
                        font-size: 32rpx;
                        font-weight: bold;
                        color: #fff;
                        margin-bottom: 8rpx;
                    }

                    .status-text {
                        font-size: 24rpx;
                        color: #fff;
                    }
                }

                .status-divider {
                    width: 2rpx;
                    height: 40rpx;
                    background: rgba(255, 255, 255, 0.3);
                }
            }
        }

        // 设备统计区域
        .device-section {
            background: #fff;
            margin: 20rpx 30rpx;
            border-radius: 12rpx;
            overflow: hidden;

            .section-header {
                display: flex;
                align-items: center;
                justify-content: space-between;
                padding: 30rpx;
                border-bottom: 1rpx solid #f0f0f0;

                .section-title {
                    font-size: 32rpx;
                    font-weight: bold;
                    color: #333;
                }

                .arrow-icon {
                    font-size: 32rpx;
                    color: #666;
                }
            }

            .device-stats {
                display: flex;
                padding: 30rpx;

                .stats-left {
                    flex: 1;
                    display: flex;
                    flex-direction: column;
                    gap: 40rpx;
                }

                .stats-right {
                    flex: 1;
                    display: flex;
                    flex-direction: column;
                    gap: 40rpx;
                }

                .stat-item {
                    position: relative;

                    .stat-number {
                        display: block;
                        font-size: 36rpx;
                        font-weight: bold;
                        color: #333;
                        margin-bottom: 8rpx;
                    }

                    .stat-label {
                        font-size: 28rpx;
                        color: #666;
                    }

                    .bubbles {
                        position: absolute;
                        right: 0;
                        top: 0;
                        display: flex;
                        flex-direction: row;
                        align-items: center;

                        .bubble {
                            padding: 4rpx 12rpx;
                            border-radius: 12rpx;
                            font-size: 20rpx;
                            color: #fff;
                            text-align: center;
                            min-width: 60rpx;
                            position: relative;
                            z-index: 1;

                            &.bubble-today {
                                background: #87CEEB;
                                z-index: 3;
                            }

                            &.bubble-yesterday {
                                background: #5A8BFF;
                                margin-left: -10rpx; // 5个像素的覆盖
                                z-index: 2;
                            }

                            &.bubble-month {
                                background: #427AF5;
                                margin-left: -10rpx; // 5个像素的覆盖
                                z-index: 1;
                            }
                        }
                    }
                }
            }
        }
    }
</style>
